package com.rxnetwork.sample.test;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2017/7/10.
 */

public class JBWebModel {
    public String picUrl;
    public List<String> imgArray;
    public int x;
    public int y;
    public int height;
    public int width;
    public int index;

    public JBWebModel(JSONObject jsonObject) {
        parse(jsonObject);
    }

    /**
     * 解析json字符串
     */
    private void parse(JSONObject jsonObject) {
        try {
            JSONObject object = jsonObject;

            picUrl = object.getString("picUrl");
            JSONArray jsonArray = object.getJSONArray("imgArray");
            imgArray = new ArrayList<>();
            for (int i = 0; i < jsonArray.length(); i++){
                imgArray.add(jsonArray.getString(i));
            }
            x = object.getInt("x");
            y = object.getInt("y");
            height = object.getInt("height");
            width = object.getInt("width");
            index = object.getInt("index");
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }
}
